<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-09-18 17:18:53
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: BOM成品工艺辅料版别
 */

namespace App\Models;


class ProColorRevItem extends BaseModel
{
    protected $casts = [
        'rate' => 'double',
    ];
    public $timestamps = true;
    public $table = "basedata_pro_color_rev_item";
    protected $guarded = [];

    public function main()
    {
        return $this->belongsTo(ProColorRev::class);
    }
    public function ounit()
    {
        return $this->belongsTo(Dic::class, "ounit_id", "key")->where(function ($q) {
            $q->where("code", 'AuxiliaryOUnit');
        });
    }
    public function uunit()
    {
        return $this->belongsTo(Dic::class, "uunit_id", "key")->where(function ($q) {
            $q->where("code", 'AuxiliaryUUnit');
        });
    }
    public function material()
    {
        return $this->belongsTo(Material::class);
    }
}
